# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=libtasn1
pkgname=('libtasn1' 'libtasn1-devel')
pkgver=4.7
pkgrel=1
pkgdesc="A library for Abstract Syntax Notation One (ASN.1) and Distinguish Encoding Rules (DER) manipulation."
arch=('i686' 'x86_64')
license=('GPL3' 'LGPL')
url="http://www.gnu.org/software/libtasn1/"
makedepends=('gcc' 'texinfo' 'make' 'patch')
source=(http://ftp.gnu.org/gnu/libtasn1/${pkgname}-${pkgver}.tar.gz{,.sig}
        libtasn1-3.3-msys2.patch)
sha256sums=('a40780dc93fc6d819170240e8ece25352058a85fd1d2347ce0f143667d8f11c9'
            'SKIP'
            'd6934f9cc97d01df148cf879961a96cb41e8874d31b4f89d0b80247aabbc4143')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i $srcdir/libtasn1-3.3-msys2.patch
  autoreconf -i
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR=$srcdir/dest install
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package_libtasn1() {
  depends=('info')
  groups=('libraries')
  install=libtasn1.install

  mkdir -p $pkgdir/usr/bin
  cp -f $srcdir/dest/usr/bin/*.dll $pkgdir/usr/bin/
  cp -rf $srcdir/dest/usr/share $pkgdir/usr/
}

package_libtasn1-devel() {
  pkgdesc="Libtasn1 headers and libraries"
  groups=('development')
  depends=("libtasn1=${pkgver}")

  mkdir -p $pkgdir/usr/bin
  cp -f $srcdir/dest/usr/bin/*.exe $pkgdir/usr/bin/
  cp -rf $srcdir/dest/usr/include $pkgdir/usr/
  cp -rf $srcdir/dest/usr/lib $pkgdir/usr/
}
